const fs = require('fs')

function readFilePromise(fpath){
    return new Promise(function(resolve,reject){
        fs.readFile(fpath,'utf-8',(err,results)=>{
            if(err) return reject(err)
            resolve(results)
        })
    })
}


// ES7中关键字async只能写在function的前面
async function test() {
    const r1 = await readFilePromise(__dirname+'/files/1.txt')
    console.log(r1)
    const r2 = await readFilePromise(__dirname+'/files/2.txt')
    console.log(r2)
    const r3 = await readFilePromise(__dirname+'/files/3.txt')
    console.log(r3)
    console.log('写在最后面')
}
test()
console.log('执行完毕')